package com.liuxin.zhiyuan.shujuzhongxin.service.impl;

import com.liuxin.common.utils.PageUtils;
import com.liuxin.zhiyuan.shujuzhongxin.domain.dto.MajorInfoListDTO;
import com.liuxin.zhiyuan.shujuzhongxin.domain.po.MajorSubjectEntity;
import com.liuxin.zhiyuan.shujuzhongxin.mapper.MajorSubjectMapper;
import com.liuxin.zhiyuan.shujuzhongxin.mapper.MajorinfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liuxin.common.utils.Query;

import com.liuxin.zhiyuan.shujuzhongxin.domain.po.MajorinfoEntity;
import com.liuxin.zhiyuan.shujuzhongxin.service.MajorinfoService;


@Service
public class MajorinfoServiceImpl extends ServiceImpl<MajorinfoMapper, MajorinfoEntity> implements MajorinfoService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<MajorinfoEntity> page = this.page(
                new Query<MajorinfoEntity>().getPage(params),
                new QueryWrapper<MajorinfoEntity>()
        );

        return new PageUtils(page);
    }


    @Autowired
    MajorSubjectMapper majorSubjectMapper;

    @Override
    public PageUtils listWithTree(String level) {
        List<MajorSubjectEntity> majorSubjectList = majorSubjectMapper.listWithTree(level);
        //查询专业树列表
        return null;
    }

    @Override
    public PageUtils queryMajorInfoPage(Map<String, Object> params) {
        // 构建查询条件
        String majorName = (String) params.get("majorName");
        String categoryName = (String) params.get("categoryName");
        String subjectName = (String) params.get("subjectName");
        // 创建分页对象
        IPage<MajorInfoListDTO> page = new Query<MajorInfoListDTO>().getPage(params);
        // 执行自定义SQL查询
        IPage<MajorInfoListDTO> resultPage = this.baseMapper.selectMajorInfoPage(page, majorName, categoryName, subjectName);
        return new PageUtils(resultPage);
    }




}


















